<?php

namespace addons\zzyy\library;

use fast\Http;
use think\Log;

/**
 * 用来接收后和Saas_center通信的
 */
class SaasCenter
{

    public static function getOpenPlatformInfoAndRefreshToken($appletId)
    {
        $headers = ['Content-Type: application/json'];
        $options = [
            CURLOPT_HTTPHEADER => $headers
        ];

        $url = 'https://zzyycenter.yakexi.tech/yakexiapi/applet/getOpenFlatformInfoAndRefreshToken';
        $result = Http::get($url, ['applet_id' => $appletId], $options);

        $returnData = json_decode($result,  true);

        if (1 == $returnData['code']) {
            return $returnData['data'];
        } else {
            Log::record($returnData, 'saas_center');
            return false;
        }
    }

    public static function getOpenPlatformMerchantIsp()
    {
        $headers = ['Content-Type: application/json'];
        $options = [
            CURLOPT_HTTPHEADER => $headers
        ];

        $url = 'https://zzyycenter.yakexi.tech/yakexiapi/applet/getOpenPlatformMerchantIsp';
        $result = Http::get($url, [], $options);

        $returnData = json_decode($result,  true);

        if (1 == $returnData['code']) {
            return $returnData['data'];
        } else {
            Log::record($returnData, 'saas_center');
            return false;
        }
    }
}
